package sanlc;
// 非机动车类（父类）
class NonMotorVehicle {
    // 抽象方法，子类必须实现该方法
    public void productIntroduction() {
        System.out.println("这是一个非机动车产品。");
    }
}

// 自行车类（继承非机动车类）
class Bicycle extends NonMotorVehicle {
    private String color;
    private String brand;
    private int seats;

    public Bicycle(String color, String brand, int seats) {
        this.color = color;
        this.brand = brand;
        this.seats = seats;
    }

    @Override
    public void productIntroduction() {
        System.out.println("自行车产品介绍：");
        System.out.println("颜色: " + color);
        System.out.println("品牌: " + brand);
        System.out.println("座位数: " + seats);
    }
}

// 三轮车类（继承非机动车类）
class Tricycle extends NonMotorVehicle {
    private String color;
    private String brand;
    private int wheels;

    public Tricycle(String color, String brand, int wheels) {
        this.color = color;
        this.brand = brand;
        this.wheels = wheels;
    }

    @Override
    public void productIntroduction() {
        System.out.println("三轮车产品介绍：");
        System.out.println("颜色: " + color);
        System.out.println("品牌: " + brand);
        System.out.println("轮子数: " + wheels);
    }
}

// 电动车类（继承非机动车类）
class ElectricBike extends NonMotorVehicle {
    private String color;
    private String brand;
    private int batteryLevel;

    public ElectricBike(String color, String brand, int batteryLevel) {
        this.color = color;
        this.brand = brand;
        this.batteryLevel = batteryLevel;
    }

    @Override
    public void productIntroduction() {
        System.out.println("电动车产品介绍：");
        System.out.println("颜色: " + color);
        System.out.println("品牌: " + brand);
        System.out.println("电池电量: " + batteryLevel + "%");
    }
}

// 测试类
public class slc {
    public static void main(String[] args) {
        // 创建自行车对象
        Bicycle bicycle = new Bicycle("红色", "捷安特", 2);
        System.out.println("自行车自我介绍：");
        bicycle.productIntroduction();
        System.out.println();

        // 创建三轮车对象
        Tricycle tricycle = new Tricycle("黄色", "永久", 3);
        System.out.println("三轮车自我介绍：");
        tricycle.productIntroduction();
        System.out.println();

        // 创建电动车对象
        ElectricBike electricBike = new ElectricBike("白色", "雅迪", 80);
        System.out.println("电动车自我介绍：");
        electricBike.productIntroduction();
    }
}
